package org.lalib.mediator;

import java.util.List;

import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;
import org.lalib.acquire.IMediator;
import org.lalib.entity.object.EFood;
import org.lalib.foundation.FDataAccess;
import org.springframework.stereotype.Repository;

@Repository(value = "mFood")
public class MFood extends FDataAccess<EFood> implements IMediator {

	private static final long serialVersionUID = 1L;

	@Override
	protected Class<EFood> getClassType() {
		return EFood.class;
	}

	@SuppressWarnings("unchecked")
	public List<EFood> getFoodListForGivenName(String name) {
		return (List<EFood>) getSession().createCriteria(EFood.class).add(Restrictions.ilike("name", name, MatchMode.ANYWHERE)).list();
	}

	@SuppressWarnings("unchecked")
	public List<EFood> getAllFoods() {
		return (List<EFood>) getSession().createCriteria(EFood.class).list();
	}
}
